package com.denso.store.admin.administrator;

import com.denso.store.common.model.Admin;

import java.util.Date;
import java.util.List;


/**
 * Created by lijian on 2017/10/26.
 */
public class AdminService {

    private static final Admin dao = new Admin();

    public List<Admin> findByTpe(int type) {
        List<Admin> adminList = dao.find("select * from admin where type=? order by id desc", type);
        return adminList;
    }

    public Admin findById(int id) {
        return dao.findById(id);
    }

    public boolean save(Admin admin) {
        return admin.save();
    }

    public boolean update(Admin admin) {
        admin.setUpdateTime(new Date());
        return admin.update();
    }

    public boolean deleteById(int id) {
        return dao.deleteById(id);
    }

    public Admin login(int type, String name, String password) {
        Admin admin = dao.findFirst("select * from admin where type=? and name=? and password=?", type, name, password);
        return admin;
    }
}
